

<?php

class CTableDraw
{

public static $instance; 

public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new CTableDraw();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	

function DrawTable($title,$table,$campos,$way)//obligatorio ID como campo inicial
    {
 
    if($way!=17){
    $qu = "select idGuide,concat_ws('',FirstNamGui,' ',LastNamGui) as NomApe,DocNumGui,MailGui,TelGui,WebPagGui,GuiOrTc,CUENTA_idCue,CITY_idCit
            from guidetc";
         
    
     echo "<div id='content_area_user_title'>";
    echo "<h2> $title</h2>";
    echo "</div>";


    echo "<form>";						
    echo "<form id='filter-form'>Buscar TC: <input name='filter' id='filter' value='' maxlength='30' size='30' type='text'></form><br>";
    echo "</form>";
   
    echo "<div class='usersettings_statistics'>"; 
 


    echo "<table class='food_planner'>";
    
    
    
    
    echo "<tbody><tr style='display: table-row;'>";

       echo "<thead>";
    echo "<tr>";    
        foreach($campos as $id=>$valor){
                echo "<th>$valor</th>";
                }
    echo "</tr>";    
    echo "</thead>";


    echo "<tr class='odd'>";

    // $qu="select*from $table";
    $table=CModelo::getInstance()->getData($qu);
//var_dump($table);
    $cont=0;
    
    $ruta=CConfig::getInstance()->rutalocal;
    
    
    foreach($table as $campo => $valor)
    { 



$cont=$cont+1;
if($cont%2){




echo "<tr class='odd'>";
$i="";$cont=0;
foreach($valor as $id=>$val){
    if($cont==0){$i=$val;}
    if($cont==8){$val=$val;
                    $qu = "select NamCit, CouNameCit from City where idCit=$val";$re=CModelo::getInstance()->getData($qu);
                    foreach($re as $r=>$c){$tab1=$c;
                        foreach($tab1 as $r1=>$c1){
                            $NamCit[]=$c1;
                        }
                    }
                    $nval = base64_encode($NamCit[0]);
                    $val= "<a href='index.php?idCit=$val&nval=$nval' title='Ver operadores de $NamCit[0]'> $NamCit[0] ($NamCit[1])</a>";
                    
                }
                
    echo "<td>$val</td>";$cont=$cont+1;
}
/*---------------------------------------------------------------------------*/
// las referencias debbden de ser modificadas deacuerdo al directorio
//
/*---------------------------------------------------------------------------*/

echo "<td> <input type='button' onClick=\"parent.location='$ruta/MDGuideData/GuideServices/CResumeServices.php?codigo=$i'\" value='Ver servicios'>  </td>";

echo "<td> <input type='button' onClick=\"parent.location='$ruta/MDGuideData/CGuideTable.php?codigo=$i&default=1'\" value='Ver tours'>  </td>";

echo "<td> <a href='$ruta/MDGuideData/CGuideEdit.php?codigo=$i&default=1'> <img src='../MDTour/images/edit.png' width='32' title='Editar datos del guía $i'/> </a> </td>";
echo "<td> <input type=image src='../MDTour/images/trash.png' width='32' title='Eliminar operador $i' onclick='confirm_del($i)' value='Terminar registro'> </td>";
echo "</tr>";
}
else
{

echo "<tr class='even'> ";
$i2="";$cont2=0;
foreach($valor as $id=>$val){
    if($cont2==0){$i2=$val;}
    if($cont2==8){$val=$val;
                    $qu = "select NamCit, CouNameCit from City where idCit=$val";$re=CModelo::getInstance()->getData($qu);
                    foreach($re as $r=>$c){$tab1=$c;
                        foreach($tab1 as $r1=>$c1){
                            $NamCit[]=$c1;
                        }
                    }
                    $val= "<a href='index.php?idCit=$val' title='Ver operadores de $NamCit[0]'> $NamCit[0] ($NamCit[1])</a>";
                }
                
    echo "<td>$val</td>";$cont2=$cont2+1;
}
echo "<td> <input type='button' onClick=\"parent.location='$ruta/MDGuideData/GuideServices/CResumeServices.php?codigo=$i2'\" value='Ver servicios'>  </td>";
echo "<td> <input type=button onClick=\"parent.location='$ruta/MDGuideData/CGuideTable.php?codigo=$i2&default=1'\" value='Ver tours'>  </td>";

echo "<td> <a href='$ruta/MDGuideData/CGuideEdit.php?codigo=$i2&default=1'> <img src='../MDTour/images/edit.png' width='32' title='Editar datos del guía $i2'/> </a> </td>";
echo "<td> <input type=image src='../MDTour/images/trash.png' width='32' title='Eliminar operador $i2' onclick='confirm_del($i2)' value='Terminar registro'> </td>";
echo "</tr>";
}

}
echo "</td></tr></tbody></table><br><br>";

} // final del if con comparacion 17
 else{
    include_once("DrawBloqueos.php"); //Dibuja una tabla pac_has_tour_has_guidetc             
    } 

 }






}
?>